package com.abner.design.patterns.interpreter;

import java.util.HashMap;


/**
 *变量的解释器
 * @author abner
 */
public class VarExpression extends Expression {

	private String key;

	public VarExpression(String key) {
		this.key = key;
	}

	/**
	 * var 就是{a=10, b=20}
	 * interpreter 根据 变量名称，返回对应值
	 * @param var
	 * @return
	 */
	@Override
	public int interpreter(HashMap<String, Integer> var) {
		return var.get(this.key);
	}
}
